package model;
import java.util.ArrayList;

public class OrderContainer
{
    private ArrayList<Order> orderList;
    private static OrderContainer instance;

    public OrderContainer() {
        orderList = new ArrayList<Order>();
    }
    
    public static OrderContainer getInstance(){
        if (instance == null) {
            instance= new OrderContainer();
        }
        return instance;
    }
    public void addOrder(Order o) 
    {
        orderList.add(o);
    }
    
    
    public ArrayList<Order> findOrder(String customerId) 
    {
        ArrayList<Order> oList = new ArrayList<Order>();
        for(Order o : orderList) 
        {
            if(o.getCustomer().getID().equals(customerId))
            {
               oList.add(o);
            }
        }
        return oList;
    }
    
    public Order getOrder(String ID)
    {
        for( Order o : orderList )
        {
            if(o.getID().equals(ID)) return o;
        }
        return null;
    }
    
    public void updateOrder(String id, String status) 
    {
        for(Order o : orderList) 
        {
            if(o.getID().equals(id))
            {
                o.setStatus(status);
            }
        }
    }
    public void deleteOrder(Order order) 
    {
        orderList.remove(order);
    }
    
}